import http from '@/utils/http'
import type { LabelValueState } from '@/types/global'

const BASE_URL = '/task/projectInfo'

export interface ProjectInfoResp {
  id: string
  name: string
  description: string
  startTime: string
  endTime: string
  createUserString: string
  updateUserString: string
}
export interface ProjectInfoDetailResp {
  id: string
  name: string
  description: string
  startTime: string
  endTime: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface ProjectInfoQuery {
  name: string
  startTime: string
  endTime: string
  sort: Array<string>
}
export interface ProjectInfoPageQuery extends ProjectInfoQuery, PageQuery {}

/** @desc 查询项目列表 */
export function listProjectInfo(query: ProjectInfoPageQuery) {
  return http.get<PageRes<ProjectInfoResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询项目详情 */
export function getProjectInfo(id: string) {
  return http.get<ProjectInfoDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增项目 */
export function addProjectInfo(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改项目 */
export function updateProjectInfo(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除项目 */
export function deleteProjectInfo(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出项目 */
export function exportProjectInfo(query: ProjectInfoQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}

/** @desc 查询项目列表 */
export function listProjectDict(query?: { status: number }) {
  return http.get<LabelValueState[]>(`${BASE_URL}/dict`, query)
}
